<?php

namespace Admin;

use Admin\Model\SongTable;
use Admin\View\Helper as AdminViewHelper;


class Module
{
	public function getAutoloaderConfig()
	{
		return array(
				'Zend\Loader\ClassMapAutoloader' => array(
						__DIR__ . '/autoload_classmap.php',
				),
				'Zend\Loader\StandardAutoloader' => array(
						'namespaces' => array(
								__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
						),
				),
		);
	}

	public function getConfig() {
		return include __DIR__ . '/config/module.config.php';
	}

	public function onBootstrap($e) {
		$app = $e->getApplication();
		$serviceManager = $app->getServiceManager();

		$serviceManager->get('viewhelpermanager')->setFactory('helper', function($sm) use ($e) {
			return new AdminViewHelper($e->getRouteMatch());
		});

	}

	public function getServiceConfig() {
		return array(
				'factories' => array(
						'Admin\Model\SongTable' => function($sm){
							$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
							$table = new SongTable($dbAdapter);
							return $table;
						},
				),
		);
	}

	public function init($moduleManager) {
		$moduleManager->loadModule('ZfcUser');
	}
}
